<template>
  <div id="app">
    <mainHeader></mainHeader>
    <div class="container" v-if="!isIndex">
      <sideNav class="nav"></sideNav>
      <router-view class="view"></router-view>
    </div>
    <router-view class="page" v-else></router-view>
    <mainFooter v-if="!isIndex"></mainFooter>
  </div>
</template>

<script>
import mainHeader from "./components/header.vue";
import mainFooter from "./components/footer.vue";
import sideNav from "./components/side-nav.vue";

export default {
  components: {
    mainHeader,
    mainFooter,
    sideNav,
  },
  name: "app",
  data() {
    return {
      init: false,
      isIndex: true,
    };
  },
  watch: {
    $route() {
      this.isIndex = this.$route.name === "index";
    },
  },
  mounted() {
    //  这里模拟数据请求
    setTimeout(() => {
      this.init = true;
    }, 3000);
  },
};
</script>

<style lang="scss">
.container {
  display: flex;
  margin: 48px auto;
  width: 90%;
  background-color: #fff;
  box-shadow: 0 4px 30px 0 rgba(223, 225, 230, 0.5);
  .nav {
    width: 210px;
    height: 100%;
  }
  .view {
    flex: 1;
    height: 100%;
    padding-bottom: 32px;
  }
}
</style>
